package com.jcl.recruit.attach.dao;

import com.jcl.recruit.attach.mapper.UploadFileMapper;
import com.jcl.recruit.attach.model.UploadFileInfo;
import com.jcl.core.db.DatabaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Component
public class UploadFileDao implements UploadFileMapper {

    @Autowired
    private UploadFileMapper uploadFileMapper;

    @Override
    public List<UploadFileInfo> findList(String corpCode,
                                         Integer ownerId,
                                         String type) {
        DatabaseContext.setCurrentContext();
        return uploadFileMapper.findList(corpCode, ownerId, type);
    }

    @Override
    public UploadFileInfo findOne(String id) {
        DatabaseContext.setCurrentContext();
        return uploadFileMapper.findOne(id);
    }

    @Override
    public int add(UploadFileInfo uploadFileInfo) {
        DatabaseContext.setContext(uploadFileInfo.getCorpCode());
        return uploadFileMapper.add(uploadFileInfo);
    }

    @Override
    public int update(UploadFileInfo uploadFileInfo) {
        DatabaseContext.setContext(uploadFileInfo.getCorpCode());
        return uploadFileMapper.update(uploadFileInfo);
    }
}
